In [43]:
import requests
from bs4 import BeautifulSoup

In [44]:
#r = requests.get("http://www.gog.com")
r = requests.get("http://pythonforengineers.com/secret/")
soup = BeautifulSoup(r.text, "lxml")

In [45]:
for pelem in soup.find_all('p'):
    print(pelem.text)


Nothin' to see here! Move along please. Thank you
· © 2016 Python For Engineers · Designed by Press Customizr · Powered by  ·

In [46]:
from selenium import webdriver

In [47]:
driver = webdriver.Firefox()

In [48]:
driver.get("http://pythonforengineers.com/secret/")

In [49]:
text = driver.find_element_by_tag_name('p')
print(text.text)


Nothin' to see here! Move along please. Thank you

Warning! Code below is very liable to break, if the web layout changes


In [50]:
button = driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div/div[1]/article/div/button")
print(button.text)


Super secret button: Don't press!

In [51]:
button2 = driver.find_element_by_xpath("//*[contains(text(), 'Super')]")
print(button2.text)


Super secret button: Don't press!

In [52]:
button2.click()

In [53]:
text = driver.find_element_by_tag_name('p')
print(text.text)


This is the secret info: The answer is 42. Always 42! Don't tell the rats.

In [55]:
driver.close()

In [ ]: